package com.zsj.juc.lock;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.LongAdder;

/**
 * @author zsj
 * @version 1.0
 * @date 2024/5/17 13:56
 * @description 原子类增强
 */
public class AtomicAdder {
    private static final Logger log = LoggerFactory.getLogger(AtomicAdder.class);
    private static AtomicInteger atomicInteger = new AtomicInteger(0);
    private static LongAdder adder = new LongAdder();

    public static void main(String[] args) {
        atomicInteger.getAndAdd(1);

        adder.increment();

        log.info("integer {} ", atomicInteger.get());
        log.info("adder {} ", adder.intValue());
    }
}
